function fig = fm_about(varargin)
% FM_ABOUT display information about the current
%         PSAT version
%
% FM_ABOUT()
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Update:    10-Feb-2003
%Update:    29-Jul-2003
%Version:   1.0.3
%
%E-mail:    federico.milano@ucd.ie
%Web-site:  faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano

global Settings Fig Path Theme

if nargin

  if ~exist('Fig'), Fig.about = -1; end
  if ~ishandle(Fig.about)
    Fig.about = findobj(get(0,'Children'),'FileName','fm_about');
  end
  switch varargin{1}

  case 'aboutdown'

    h = get(Fig.about,'Userdata');
    ph = get(h,'Position');
    pos = get(Fig.about,'CurrentPoint');
    for i = 1:length(h)
      ph1 = ph{i}(1);
      ph2 = ph{i}(2);
      ph3 = ph{i}(1) + ph{i}(3);
      ph4 = ph{i}(2) + ph{i}(4);

      if pos(1) > ph1 && pos(2) > ph2  && pos(1) < ph3 && pos(2) < ph4
        switch i
        case 1, web('mailto:federico.milano@ucd.ie');
        case 2, web('faraday1.ucd.ie/psat.html');
        case 3, web('http://groups.yahoo.com/group/psatforum');
        case 4, web('mailto:psatforum@yahoogroups.com');
        case 5, web('mailto:milano.federico@gmail.com');
        case 6, web('mailto:psatforum@yahoo.com');
        end
        break
      end

    end

  case 'aboutmove'

    h = get(Fig.about,'Userdata');
    ph = get(h,'Position');
    pos = get(Fig.about,'CurrentPoint');
    px = 1;

    if Settings.hostver >= 7.01
      pointer = 'hand';
    else
      pointer = 'crosshair';
    end

    if pos(1) > 0.3 && pos(1) < 0.9
      for i = 1:length(h)
        ph2 = ph{i}(2);
        ph4 = ph{i}(2) + ph{i}(4);
        if pos(2) > ph2 && pos(2) < ph4
          set(Fig.about,'Pointer',pointer);
          set(h,'ForegroundColor',[0 0 0]);
          set(h(i),'ForegroundColor',[1 1 0]);
          px = 0;
          break
        end
      end
    end

    if px
      set(Fig.about,'Pointer','arrow');
      set(h,'ForegroundColor',[0 0 0]);
    end

  case 'keyesc'

    tasto = get(gcf,'CurrentCharacter');
    if (double(tasto) == 13 || double(tasto) == 27), close(gcf); end

  end
  return
end

fontname = 'times';
grey = [0.725 0.725 0.725];
if ishandle(Fig.about), figure(Fig.about), return, end

h0 = figure('Color',Theme.color01, ...
  'Units', 'normalized', ...
  'Colormap',[], ...
  'CreateFcn','Fig.about = gcf;', ...
  'DeleteFcn','Fig.about = -1;', ...
  'FileName','fm_about', ...
  'KeyPressFcn','fm_about keyesc', ...
  'MenuBar','none', ...
  'Name',['About PSAT'], ...
  'NumberTitle','off', ...
  'PaperPosition',[18 180 576 432], ...
  'PaperType','A4', ...
  'PaperUnits','points', ...
  'Position',sizefig(0.35,0.45), ...
  'Resize','on', ...
  'ToolBar','none', ...
  'WindowButtonDownFcn','fm_about aboutdown', ...
  'WindowButtonMotionFcn','fm_about aboutmove');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'Enable', 'inactive', ...
  'BackgroundColor',grey, ...
  'ForegroundColor',Theme.color03, ...
  'Position',[0.05  0.05  0.9  0.9], ...
  'String','fmilano@epsl.die.unige.it', ...
  'Style','frame', ...
  'Tag','Frame1');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',14, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.703 0 0], ...
  'ListboxTop',0, ...
  'Position',[0.1      0.7382     0.8     0.14163], ...
  'String','PSAT', ...
  'Style','text', ...
  'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.251 0 0.251], ...
  'ListboxTop',0, ...
  'Position',[0.1      0.6382     0.8     0.14163], ...
  'String','Power System Analysis Toolbox', ...
  'Style','text', ...
  'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'ListboxTop',0, ...
  'Position',[0.1     0.55+0.075     0.8    0.07], ...
  'String',['Version ',Settings.version], ...
  'Style','text', ...
  'Tag','StaticText2');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'ListboxTop',0, ...
  'Position',[0.1     0.48+0.075      0.8       0.07], ...
  'String',Settings.date, ...
  'Style','text', ...
  'Tag','StaticText4');
h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'ListboxTop',0, ...
  'Position',[0.1     0.39+0.075     0.8     0.09], ...
  'String','(c) 2002-2019 Federico Milano', ...
  'Style','text', ...
  'Tag','StaticText3');
%h1 = uicontrol('Parent',h0, ...
%               'Units', 'normalized', ...
%               'BackgroundColor',Theme.color03, ...
%               'Callback','close(gcf);', ...
%               'FontWeight','bold', ...
%               'ForegroundColor',Theme.color09, ...
%               'ListboxTop',0, ...
%               'Position',[0.35  0.08  0.3  0.075], ...
%               'String','Ok', ...
%               'Tag','Pushbutton1');

h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.1 0.355 0.2 0.075], ...
  'String','E-mail:', ...
  'Style','text', ...
  'Tag','StaticText3');

h(1) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.365+0.005 0.6 0.05], ...
  'String','federico.milano@ucd.ie', ...
  'Style','text', ...
  'Tag','StaticText3');

h(5) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.315+0.005 0.6 0.05], ...
  'String','milano.federico@gmail.com', ...
  'Style','text', ...
  'Tag','StaticText3');

h(6) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.265+0.005 0.6 0.05], ...
  'String','psatforum@yahoo.com', ...
  'Style','text', ...
  'Tag','StaticText3');

h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.1 0.175 0.2 0.075], ...
  'String','Website:', ...
  'Style','text', ...
  'Tag','StaticText3');

h(2) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.185+0.005 0.6 0.05], ...
  'String','faraday1.ucd.ie/psat.html', ...
  'Style','text', ...
  'Tag','StaticText2');

h1 = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'FontName',fontname, ...
  'FontSize',11, ...
  'FontWeight','bold', ...
  'ForegroundColor',[0.0 0.0 0.502], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.1 0.1 0.2 0.075], ...
  'String','Forum:', ...
  'Style','text', ...
  'Tag','StaticText3');

h(3) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.11+0.005 0.6 0.05], ...
  'String','http://groups.yahoo.com/group/psatforum', ...
  'Style','text', ...
  'Tag','StaticText2');

h(4) = uicontrol('Parent',h0, ...
  'Units', 'normalized', ...
  'BackgroundColor',grey, ...
  'Enable','inactive', ...
  'FontName',Theme.font01, ...
  'ForegroundColor',[0 0 0], ...
  'HorizontalAlignment','left', ...
  'ListboxTop',0, ...
  'Position',[0.3 0.06+0.005 0.6 0.05], ...
  'String','psatforum@yahoogroups.com', ...
  'Style','text', ...
  'Tag','StaticText2');


set(Fig.about,'UserData',h);
if nargout > 0, fig = h0; end
